package com.huanrong.vo;

import org.apache.commons.lang.StringUtils;

import net.sf.json.JSONObject;

public class JqGridPage
{
    private Integer rows;// 每页显示的记录数
    
    private Integer page;// 当前page，从1开始
    
    private Integer start; // 当前页起始记录行号.(page-1)*rows
    
    private JSONObject filters;// 查询语句
    
    private JSONObject preFilters;// 先决条件
    
    public JSONObject getPreFilters()
    {
        return preFilters;
    }
    
    public void setPreFilters(JSONObject preFilters)
    {
        this.preFilters = preFilters;
    }
    
    public Integer getRows()
    {
        return rows;
    }
    
    public void setRows(Integer rows)
    {
        this.rows = rows;
    }
    
    public Integer getPage()
    {
        return page;
    }
    
    public void setPage(Integer page)
    {
        this.page = page;
    }
    
    public Integer getStart()
    {
        return start;
    }
    
    public void setStart(Integer start)
    {
        this.start = start;
    }
    
    public JSONObject getFilters()
    {
        return filters;
    }
    
    public void setFilters(JSONObject filters)
    {
        this.filters = filters;
    }
    
    /**
     * 对JqGridPage进行处理
     * 
     * @param page 当前页码，从1开始
     * @param rowCount 每页显示的记录数
     * @return
     */
    public static JqGridPage processPage(String page, String rowCount)
    {
        JqGridPage gridPage = new JqGridPage();
        if (StringUtils.isNotBlank(page) && StringUtils.isNotBlank(rowCount))
        {
            gridPage.setPage(Integer.valueOf(page));
            gridPage.setRows(Integer.valueOf(rowCount));
            gridPage.setStart((gridPage.getPage() - 1) * gridPage.getRows());
        }
        return gridPage;
    }
}
